/* name: P5998_nlogn
 * author: 5ab
 * created at: 2022-10-14
 */
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define ssz(x) (int((x).size()))

auto chmax = [](auto& x, auto y) { if (x < y) x = y; };
auto chmin = [](auto& x, auto y) { if (y < x) x = y; };

using ll = long long;
const int N = 5e5, lgN = 19, S = 2 << lgN;

struct gd
{
	int x1, x2, y1, y2;
}
a[N];
bool rm[N];

struct fake_list
{
	vector<int> v;
	void insert(int x)
	{
		v.push_back(x);
	}
	int top()
	{
		while (!v.empty() && rm[v.back()])
			v.pop_back();
		if (v.empty())
			return -1;
		return v.back();
	}
}
add[S * 2], val[S * 2];

inline int ls(int x) { return x << 1; }
inline int rs(int x) { return (x << 1) | 1; }

void modify(int L, int R, int l, int r, int id, int x)
{
	if (L <= l && r <= R)
	{
		add[id].insert(x);
		return;
	}
	int mid = (l + r) >> 1;
	val[id].insert(x);
	
	if (L <= mid)
		modify(L, R, l, mid, ls(id), x);
	if (mid < R)
		modify(L, R, mid + 1, r, rs(id), x);
}

int query(int L, int R, int l, int r, int id, int lim)
{
	{
		auto tmp = add[id].top();
		// cerr << "query-add: " << id << " " << tmp.first << " " << lim << endl;
		if (tmp != -1 && a[tmp].x2 >= lim)
			return tmp;
	}
	if (L <= l && r <= R)
	{
		auto tmp = val[id].top();
		// cerr << "query-val: " << id << " " << tmp.first << " " << lim << endl;
		if (tmp != -1 && a[tmp].x2 >= lim)
			return tmp;
		return -1;
	}
	int mid = (l + r) >> 1;
	
	if (L <= mid)
	{
		int tmp = query(L, R, l, mid, ls(id), lim);
		if (tmp != -1)
			return tmp;
	}
	if (mid < R)
		return query(L, R, mid + 1, r, rs(id), lim);
	return -1;
}

signed main()
{
	freopen("grid.in", "r", stdin);
	freopen("grid.out", "w", stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int c, m, n;
	
	cin >> c >> m >> n;
	for (int i = 0, x, y; i < n; i++)
	{
		cin >> x >> y, x--, y--;
		a[i] = { x, x, y, y };
	}
	sort(a, a + n, [](const gd& x, const gd& y) {
		return x.x2 < y.x2;
	});
	
	auto Q = [&](int i)
	{
		int tmp = query(a[i].y1, a[i].y2, 0, m - 1, 1, a[i].x1 - 2);
		if (tmp != -1) return tmp;
		tmp = query(a[i].y1 - 1, a[i].y2 + 1, 0, m - 1, 1, a[i].x1 - 1);
		if (tmp != -1) return tmp;
		tmp = query(a[i].y1 - 2, a[i].y2 + 2, 0, m - 1, 1, a[i].x1);
		return tmp;
	};
	
	for (int i = 0; i < n; i++)
	{
		int tmp = Q(i);
		// cerr << i << " " << tmp << endl;
		while (tmp != -1)
		{
			rm[tmp] = true;
			chmax(a[i].y2, a[tmp].y2);
			chmin(a[i].y1, a[tmp].y1);
			chmin(a[i].x1, a[tmp].x1);
			tmp = Q(i);
		}
		
		modify(a[i].y1, a[i].y2, 0, m - 1, 1, i);
	}
	
	ll sm = 0;
	for (int i = 0; i < n; i++)
		if (!rm[i])
			sm += 1ll * (a[i].x2 - a[i].x1 + 1) * (a[i].y2 - a[i].y1 + 1);
	cout << sm << endl;
	
	return 0;
}
// started coding at: 10-14 07:31